import React, { useEffect } from "react";
import { useLocation } from "react-router";
import { $browseAdd,$loveChange } from "api/index";
import { Toast } from "antd-mobile";

function List() {
  const location = useLocation();
  let { id } = location.state;
  console.log(id);
  // 添加历史记录
  const add = () => {
    let obj = {
      houseId: id,
    };
    $browseAdd(obj).then((res) => {
      console.log(res);
    });
  };
  useEffect(add, []);

  // 添加收藏
  const addLike = ()=> {
    let obj = {
        houseId: id
    }
    $loveChange(obj).then(res=> {
        Toast.show({
            icon: 'success',
            content: '收藏成功'
        })    
        // console.log(res);
    })
  }

  return (
    <div>
      <h3>详情</h3>
      <button onClick={addLike}>收藏</button>
    </div>
  );
}

export default List;
